

-- Namespace
	local _,mod = ...


-- Destruction
	local destroy = {
		-- CURRENT WITH FRAMEXML AS OF: 5.0.4
		
		['ZoneTextFrame'] = true,
		['SubZoneText'] = true,
		['AutoFollowStatus'] = true,
	}
	
	local function resetAlpha(self)
		self:nfSetAlpha(0)
	end
	
	local function hide(frame,scripts,recurse)
		if type(frame) ~= 'table' then
			frame = _G[frame]
			if type(frame) ~= 'table' or not frame.Hide then return end
		end
		
		frame:Hide()
		hooksecurefunc(frame,'Show',frame.Hide)
		if frame.SetScript then
			frame:SetScript('OnShow',frame.Hide)
		end
		
		--frame:SetParent(hidden)
		if frame.SetAttribute then
			frame:SetAttribute('statehidden',true)
		end
		
		local name = frame:GetName()
		if name then
			UIPARENT_MANAGED_FRAME_POSITIONS[name] = nil
		end
		
		frame:SetAlpha(0)
		frame.nfSetAlpha = frame.SetAlpha
		hooksecurefunc(frame,'SetAlpha',resetAlpha)
		
		if frame.EnableMouse then
			frame:EnableMouse(false)
			frame:EnableMouseWheel(false)
			frame:EnableKeyboard(false)
		end
		
		if scripts and frame.SetScript then
			frame:UnregisterAllEvents()
			hooksecurefunc(frame,'RegisterEvent',frame.UnregisterEvent)
			hooksecurefunc(frame,'RegisterAllEvents',frame.UnregisterAllEvents)
		end
		
		if frame.GetNumChildren then
			for i = 1,frame:GetNumChildren() do
				hide(select(i,frame:GetChildren()),scripts)
			end
		end
	end
	
	local function PLAYER_LOGIN()
		for frame,scripts in pairs(destroy) do
			hide(frame,scripts)
		end
		mod:event_unregister('PLAYER_LOGIN',PLAYER_LOGIN)
	end
	mod:event_register('PLAYER_LOGIN',PLAYER_LOGIN)
